import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        String filePath = "C:\\Users\\30367\\Desktop\\软件工程实验4.txt";
        try (Scanner scanner = new Scanner(new File(filePath))) {
            StringBuilder currentString = new StringBuilder();
            boolean inString = false;
            System.out.println("开始读取文件...");
            while (scanner.hasNext()) {
                String line = scanner.nextLine();
                System.out.println("正在处理行：" + line);
                for (int i = 0; i < line.length(); i++) {
                    char currentChar = line.charAt(i);
                    if (inString) {
                        if (currentChar == '\\') {
                            if (i + 1 < line.length()) {
                                i++;
                                currentString.append(line.charAt(i));
                            }
                        } else if (currentChar == '"'|| currentChar == '“') {
                            System.out.println("提取到字符串：" + currentString.toString());
                            currentString.setLength(0);
                            inString = false;
                        } else {
                            currentString.append(currentChar);
                        }
                    } else {
                        if (currentChar == '"'|| currentChar == '”') {
                            inString = true;
                        }
                    }
                }
            }
            System.out.println("文件读取完毕。");
        } catch (FileNotFoundException e) {
            e.printStackTrace();
            System.out.println("文件未找到。");
        }
    }
}